<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="/layout/common_head::commonHeader('系统参数设定')"></head>
<body class="layui-layout-body">
    <div class="layui-layout layui-layout-admin">
        <div th:include="/layout/footer::title">
        </div>

        <div class="layui-body hstitlewithtitle">
            <div class="layui-container">
                <br>
                <blockquote class="layui-elem-quote">
                    说明:系统参数设定
                </blockquote>
                <form action="/settingup" class="layui-form layui-form-pane" method="post" id="settingForm"
                      lay-filter="settingForm">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">系统名称</label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" lay-verify="sysname" name="sysname" maxlength="7"
                                       value="" autocomplete="off"/>
                            </div>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">系统开放</label>
                            <div class="layui-input-block layui-input">
                                <input type="checkbox" value="0" checked name="sysStatus" lay-skin="switch" lay-text="开放|关闭">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div th:include="/layout/footer::footer">
        </div>
    </div>

    <script th:replace="/layout/common_js::onloadjs"></script>
    <script type="text/javascript">
        //JavaScript代码区域
        layui.use(['element', 'form', 'layer'], function () {
            var element = layui.element,
                form = layui.form,
                layer = layui.layer;

            layer.config({
                title: ['操作提示', 'font-size:14px;'],
                closeBtn: 0,
                time: 2000,
                anim: 1,
                scrollbar: false
            });

            //自定义校验
            form.verify({
                sysname: function (value) {
                    if (value.length > 7) {
                        return '系统名称不能超过7个字符';
                    } else if (value == '') {
                        return '系统名称不能为空';
                    }
                }
            });

            //表单初始赋值
            form.val('settingForm', {
                "sysname": "后台管理系统" // "name": "value"
            });

            form.on('submit(demo1)', function (data) {

                /* $.post(,, );*/

                $.ajax({
                    type: 'POST',
                    url: '/super/setting',
                    dataType: 'application/json',
                    data: JSON.stringify(data.field),
                    success: function (res) {
                        layer.alert("回调函数", {
                            icon: 1,
                            skin: 'layer-ext-moon'
                        });
                    }
                });

                /*layer.alert(JSON.stringify(data.field), {
                    icon: 1,
                    skin: 'layer-ext-moon'
                });*/
                return false;
            });

        });

        function adminUser() {
            $.post('/admin/user/1', function (res) {
                console.log(res);
            });
        }
    </script>
</body>
</html>
